<? 
session_start();
if(!session_is_registered(uid)){
    echo "You have to login to view this page!</br></br>";
    echo "Click here to return to the "; 
    echo '<a href="./../index.php" title="Login">Login Page</a></br></br>';
    echo "Or sign up using this link ";
    echo '<a href="./../Registration/registration.html" title="Registration">Registration Page</a>';
exit();
}
else

    //Manual SQL Connection
    $con = mysql_connect("localhost", "root", "root") or die ( "Error connectiong to DB: ".mysql_error());
       
    mysql_select_db("reeferslog", $con) or die ( "Error selecting specific DB, reefeerslog: ".mysql_error());
    
    //Prompts for deletion
    if (!isset($_GET['do']) || $_GET['do'] !=1) {
    
       switch($_GET['type']) {
        case 'mait':
            echo 'Are you sure you want to delete this maintenance activity? <br\>';    
        break;
       
        case 'water':
            echo 'Are you sure you want to delete this water change? <br\>';    
        break;
       }
        
    echo '<a href="' . $_SERVER['REQUEST_URI'] . '&do=1">Yes</a> '; //yes delete
    echo 'or <a href="maintenancelog.php">No</a>'; //no return to maintenance log
    } else {
        switch ($_GET['type']) {
            case 'mait':
                //Query to delete value
                $delete = "delete from maintenance where user_id= '".$_SESSION['uid'] ."' and m_date='".$_GET['m_date']."'";
                
                $result = mysql_query($delete,$con) or die('Error: ' . mysql_error());
?>

                <p style="text-align: center;"> Your husbandry activity has been deleted.</br>
                    <a href ="./../WelcomePage/WelcomePage.php">Return to Categories</a></br>
                    <a href ="maintenancelog.php">Return to Maintenance Log</a></p>
<?php
            case 'water':
                //Query to delete value
                $delete = "delete from waterchange where user_id= '".$_SESSION['uid'] ."' and change_date='".$_GET['change_date']."'";
                
                $result = mysql_query($delete,$con) or die('Error: ' . mysql_error());
?>

                <p style="text-align: center;"> Your water change has been deleted.</br>
                    <a href ="./../WelcomePage/WelcomePage.php">Return to Categories</a></br>
                    <a href ="waterchangelog.php">Return to Water Change Log</a></p>
<?php   
    break;
        }
    }
?>